import{reqTradeInfoData} from '@/api'

const state = {
  userAddressList: [],
  tradeInfo:[]
}

const actions = {
  //获取订单中的尚品数据
  async getTradeInfoData({ commit }) {
    const result = await reqTradeInfoData()
    if (result.code === 200) {
      commit('commodity_data',result.data)
    } else {
      console.log(result.message);
    }
  }
}

const mutations = {
  //储存结算商品的数据
  commodity_data(state,data) {
    state.tradeInfo=data
  }
}

const getters = {
  //商品列表

  detailArrayList(state) {
    return state.tradeInfo.detailArrayList
  },
    // 商品总金额
    originalTotalAmount() {
      return state.tradeInfo.originalTotalAmount
    },
    // 实付金额
    totalAmount() {
      return state.tradeInfo.totalAmount
    },
    // 商品数量
    totalNum() {
      return state.tradeInfo.totalNum
    },
    // 订单编号
    tradeNo() {
      return state.tradeInfo.tradeNo
    }
}

export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters
}